[IA64] Map vcpu memory mapped registers into guest psudo physical address space
authorawilliam@xenbuild2.aw <awilliam@xenbuild2.aw>
Thu, 7 Dec 2006 21:53:47 +0000 (14:53 -0700)
committerawilliam@xenbuild2.aw <awilliam@xenbuild2.aw>
Thu, 7 Dec 2006 21:53:47 +0000 (14:53 -0700)
Assign vcpu memory mapped registers into guest psudo physical address space
for foreign domain page mapping. This is used by domain save.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
xen/arch/ia64/xen/domain.c
xen/include/asm-ia64/grant_table.h

index 0be27db0536e056ae1afb993cc397d292ec41e7e..8406c127089ab6bbe251e8c3c2466adc0706fdb9 100644 (file)
@@ -308,6 +308,16 @@ void relinquish_vcpu_resources(struct vcpu *v)
     if (HAS_PERVCPU_VHPT(v->domain))
         pervcpu_vhpt_free(v);
     if (v->arch.privregs != NULL) {
+        // this might be called by arch_do_domctl() with XEN_DOMCTL_arch_setup()
+        // for domVTi.
+        if (!(atomic_read(&v->domain->refcnt) & DOMAIN_DESTROYED)) {
+            unsigned long i;
+            for (i = 0; i < XMAPPEDREGS_SIZE; i += PAGE_SIZE)
+                guest_physmap_remove_page(v->domain,
+                    IA64_XMAPPEDREGS_PADDR(v->vcpu_id) + i,
+                    virt_to_maddr(v->arch.privregs + i));
+        }
+
         free_xenheap_pages(v->arch.privregs,
                            get_order_from_shift(XMAPPEDREGS_SHIFT));
         v->arch.privregs = NULL;
@@ -367,6 +377,15 @@ int vcpu_initialise(struct vcpu *v)
                for (i = 0; i < (1 << order); i++)
                    share_xen_page_with_guest(virt_to_page(v->arch.privregs) +
                                              i, d, XENSHARE_writable);
+               /*
+                * XXX IA64_XMAPPEDREGS_PADDR
+                * assign these pages into guest pseudo physical address
+                * space for dom0 to map this page by gmfn.
+                * this is necessary for domain save, restore and dump-core.
+                */
+               for (i = 0; i < XMAPPEDREGS_SIZE; i += PAGE_SIZE)
+                   assign_domain_page(d, IA64_XMAPPEDREGS_PADDR(v->vcpu_id) + i,
+                                      virt_to_maddr(v->arch.privregs + i));
 
                tlbflush_update_time(&v->arch.tlbflush_timestamp,
                                     tlbflush_current_time());
@@ -509,7 +528,8 @@ void arch_getdomaininfo_ctxt(struct vcpu *v, struct vcpu_guest_context *c)
        struct vcpu_extra_regs *er = &c->extra_regs;
 
        c->user_regs = *vcpu_regs (v);
-       c->privregs_pfn = virt_to_maddr(v->arch.privregs) >> PAGE_SHIFT;
+       c->privregs_pfn = get_gpfn_from_mfn(virt_to_maddr(v->arch.privregs) >>
+                                           PAGE_SHIFT);
 
        /* Fill extra regs.  */
        for (i = 0; i < 8; i++) {
index 895d1ee936638199611156bcb01d4c81e45f1916..6b62d6abd37b8c14b0f10dacd0636f021fb1671c 100644 (file)
@@ -30,9 +30,14 @@ void guest_physmap_add_page(struct domain *d, unsigned long gpfn, unsigned long
  */
 /* Guest phsyical address of shared_info */
 #define IA64_SHARED_INFO_PADDR (1UL << 40)
+/* Guest phsyical address of mapped_regs */
+#define IA64_XMAPPEDREGS_BASE_PADDR     (IA64_SHARED_INFO_PADDR + XSI_SIZE)
+#define IA64_XMAPPEDREGS_PADDR(vcpu_id)             \
+    (IA64_XMAPPEDREGS_BASE_PADDR +                  \
+     (vcpu_id) * max_t(unsigned long, PAGE_SIZE, XMAPPEDREGS_SIZE))
 
 /* Guest physical address of the grant table.  */
-#define IA64_GRANT_TABLE_PADDR  (IA64_SHARED_INFO_PADDR + XSI_SIZE)
+#define IA64_GRANT_TABLE_PADDR  IA64_XMAPPEDREGS_PADDR(NR_CPUS)
 
 #define gnttab_shared_maddr(d, t, i)                        \
     virt_to_maddr((char*)(t)->shared + ((i) << PAGE_SHIFT))